package com.ruoyi.web.controller.admin;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.BdmSignIn;
import com.ruoyi.system.service.IBdmSignInService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 签到Controller
 * 
 * @author ruoyi
 * @date 2024-12-13
 */
@RestController
@RequestMapping("/system/in")
public class BdmSignInController extends BaseController
{
    @Autowired
    private IBdmSignInService bdmSignInService;

    /**
     * 查询签到列表
     */
    @GetMapping("/list")
    public TableDataInfo list(BdmSignIn bdmSignIn)
    {
        startPage();
        List<BdmSignIn> list = bdmSignInService.selectBdmSignInList(bdmSignIn);
        return getDataTable(list);
    }

    /**
     * 导出签到列表
     */
    @Log(title = "签到", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BdmSignIn bdmSignIn)
    {
        List<BdmSignIn> list = bdmSignInService.selectBdmSignInList(bdmSignIn);
        ExcelUtil<BdmSignIn> util = new ExcelUtil<BdmSignIn>(BdmSignIn.class);
        util.exportExcel(response, list, "签到数据");
    }

    /**
     * 获取签到详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bdmSignInService.selectBdmSignInById(id));
    }

    /**
     * 修改签到
     */
    @Log(title = "签到", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BdmSignIn bdmSignIn)
    {
        return toAjax(bdmSignInService.updateBdmSignIn(bdmSignIn));
    }

    /**
     * 删除签到
     */
    @Log(title = "签到", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bdmSignInService.deleteBdmSignInByIds(ids));
    }
}
